Skip to content

feat: Allow overriding the sampling rate. - #1284

Open
darrell-roberts wants to merge 1 commit into
getsentry:masterfrom
darrell-roberts:darrell/push-nnsnopqlnrqq
Open

feat: Allow overriding the sampling rate.#1284
darrell-roberts wants to merge 1 commit into
getsentry:masterfrom
darrell-roberts:darrell/push-nnsnopqlnrqq

Conversation

@darrell-roberts

Copy link
Copy Markdown

Allow for a user defined function for setting the sampling rate. Similar to Python SDK https://docs.sentry.io/platforms/python/sampling/#dynamically-sampling-error-events

Description

Allow defining a function that overrides the sampling rate. For example you have a sampling rate set below 100% but you have certain events that should always be 100%. This allows for a user defined function to provide a sample rate override otherwise falls back to the defined sampling rate.

Issues

#1127

@darrell-roberts
darrell-roberts requested a review from a team as a code owner August 8, 2026 16:52
Comment thread sentry-core/src/clientoptions.rs
@darrell-roberts
darrell-roberts force-pushed the darrell/push-nnsnopqlnrqq branch from fe9a608 to dc3d1ef Compare August 8, 2026 17:07
Comment thread sentry-core/src/client/mod.rs
Allow for a user defined function for setting the sampling rate.
Similar to Python SDK https://docs.sentry.io/platforms/python/sampling/#dynamically-sampling-error-events
@darrell-roberts
darrell-roberts force-pushed the darrell/push-nnsnopqlnrqq branch from dc3d1ef to 628ad92 Compare August 10, 2026 14:05

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 628ad92. Configure here.

before_send_log: None,
enable_metrics: true,
before_send_metric: None,
override_sampling_rate: None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug omits new callback

Low Severity

ClientOptions’s manual Debug impl reports every other hook callback (before_send, before_breadcrumb, before_send_log, before_send_metric) but not override_sampling_rate. Debug output therefore hides whether a sampling override is configured.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 628ad92. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant